package com.lovetemperature.service.impl;

import java.util.List;

import com.lovetemperature.dao.Dao;
import com.lovetemperature.model.GoodCategory;
import com.lovetemperature.model.Stock;
import com.lovetemperature.service.StockService;

public class StockServiceImpl implements StockService{
	private Dao<Stock> stockDao;

	@Override
	public void addStock(Stock stock) {
		stockDao.save(stock);
	}

	public Dao<Stock> getStockDao() {
		return stockDao;
	}

	public void setStockDao(Dao<Stock> stockDao) {
		this.stockDao = stockDao;
	}

	@Override
	public List<Stock> findByCategory(GoodCategory category) {
		return stockDao.findByField("goodSet.good.category", category.toString());
	}

	@Override
	public Stock findById(Long stockId) {
		return stockDao.findById(stockId);
	}

	@Override
	public void update(Stock stock) {
		stockDao.update(stock);
	}

	@Override
	public void delect(Stock stock) {
		stockDao.delect(stock);
	}

}
